package com.example.dubbo.consumer.stub;

import com.example.dubbo.common.bean.User;
import com.example.dubbo.common.service.UserService;


public class UserServiceStub implements UserService {

    private final UserService userService;

    /**
     * 传入的是 userService 远程的代理对象
     */
    public UserServiceStub(UserService userService) {
        super();
        this.userService = userService;
    }

    @Override
    public User add(User user) {
        try {
            return userService.add(user);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public User get(Integer id) {
        try {
            return userService.get(id);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}